package com.ruoyi.system.service.impl;

import java.util.List;
import com.ruoyi.common.core.utils.DateUtils;
import com.ruoyi.system.domain.SysBusiness;
import com.ruoyi.system.domain.parm.SysPreferentialParm;
import com.ruoyi.system.exception.GlobalSysException;
import com.ruoyi.system.service.ISysBusinessService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.SysPreferentialMapper;
import com.ruoyi.system.domain.SysPreferential;
import com.ruoyi.system.service.ISysPreferentialService;

/**
 * 商家价格配置Service业务层处理
 * 
 * @author ruoyi
 * @date 2024-04-04
 */
@Service
public class SysPreferentialServiceImpl implements ISysPreferentialService 
{
    @Autowired
    private SysPreferentialMapper sysPreferentialMapper;
    @Autowired
    private ISysBusinessService sysBusinessService;
    /**
     * 查询商家价格配置
     * 
     * @param id 商家价格配置主键
     * @return 商家价格配置
     */
    @Override
    public SysPreferential selectSysPreferentialById(String id)
    {
        return sysPreferentialMapper.selectSysPreferentialById(id);
    }

    /**
     * 查询商家价格配置列表
     * 
     * @param sysPreferential 商家价格配置
     * @return 商家价格配置
     */
    @Override
    public List<SysPreferential> selectSysPreferentialList(SysPreferential sysPreferential)
    {
        return sysPreferentialMapper.selectSysPreferentialList(sysPreferential);
    }

    /**
     * 新增商家价格配置
     * 
     * @param sysPreferential 商家价格配置
     * @return 结果
     */
    @Override
    public int insertSysPreferential(SysPreferential sysPreferential)
    {
        sysPreferential.setCreateTime(DateUtils.getNowDate());
        return sysPreferentialMapper.insertSysPreferential(sysPreferential);
    }

    /**
     * 修改商家价格配置
     * 
     * @param sysPreferential 商家价格配置
     * @return 结果
     */
    @Override
    public int updateSysPreferential(SysPreferential sysPreferential)
    {
        sysPreferential.setUpdateTime(DateUtils.getNowDate());
        return sysPreferentialMapper.updateSysPreferential(sysPreferential);
    }


    /**
     * 批量删除商家价格配置
     *
     * @param ids 需要删除的商家价格配置主键
     * @return 结果
     */
    @Override
    public int deleteSysPreferentialByIds(String[] ids,String businessId)
    {
        SysBusiness bu = sysBusinessService.getUserInfo();
        if(bu==null){
            throw new GlobalSysException("用户未登陆");
        }


        return sysPreferentialMapper.deleteSysPreferentialByIds(ids ,bu.getId());
    }

    /**
     * 删除商家价格配置信息
     * 
     * @param id 商家价格配置主键
     * @return 结果
     */
    @Override
    public int deleteSysPreferentialById(String id,String businessId)
    {
        return sysPreferentialMapper.deleteSysPreferentialById(id,businessId);
    }

    @Override
    public  List<SysPreferential> selectSysPreferentialByParkingSpacesId( String parkingSpacesId) {

        return sysPreferentialMapper.selectSysPreferentialByParkingSpacesId(parkingSpacesId);
    }
}
